package com.duyutian.zhanglong.p33JavaNio体系;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;

public class NioTest3 {
    public static void main(String[] args) throws Exception {
        FileInputStream input = new FileInputStream("input");
        FileOutputStream output = new FileOutputStream("output");
        FileChannel channelIn = input.getChannel();
        FileChannel channelOut = output.getChannel();
        ByteBuffer allocate = ByteBuffer.allocate(512);
        while (channelIn.read(allocate) != -1) {
            allocate.flip();
            channelOut.write(allocate);
            allocate.clear();
        }
        output.close();
        input.close();
    }
}
